package com.smzd.framework.system.actions;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smzd.framework.core.actions.AbstractUserOwnedController;
import com.smzd.framework.core.business.IFGService;
import com.smzd.framework.system.business.UserBindService;
import com.smzd.framework.system.domain.User;
import com.smzd.framework.system.domain.UserBind;
import com.smzd.framework.utils.db.ORPage;

@Controller
@RequestMapping("/system/userbinds")
public class UserBindController extends AbstractUserOwnedController<UserBind> {
    @Autowired
    private UserBindService service;

    @Override
    protected IFGService<UserBind> getService() {
        return service;
    }

    @RequestMapping(value = "/add", method = RequestMethod.GET)
    @Override
    public String toAddPage(Map<String, Object> model, UserBind elem, BindingResult result) throws Exception {
        return super.toAddPage(model, elem, result);
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    @Override
    public String postAddData(Map<String, Object> model, UserBind elem, BindingResult result) throws Exception {
        return super.postAddData(model, elem, result);
    }

    @RequestMapping(method = RequestMethod.GET)
    @Override
    public String toListPage(Map<String, Object> model, UserBind elem, BindingResult result) throws Exception {
        return super.toListPage(model, elem, result);
    }

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    @Override
    public String getListData(Map<String, Object> model, ORPage<User, UserBind> page, BindingResult result)
            throws Exception {
        return super.getListData(model, page, result);
    }

    @RequestMapping(value = "/edit", method = RequestMethod.GET)
    @Override
    public String toEditPage(Map<String, Object> model, UserBind elem, BindingResult result) throws Exception {
        elem = service.getItemById(elem.getId());
        return super.toEditPage(model, elem, result);
    }

    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    @ResponseBody
    @Override
    public String postEditData(Map<String, Object> model, UserBind elem, BindingResult result) throws Exception {
        return super.postEditData(model, elem, result);
    }

    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    @ResponseBody
    @Override
    public String postRemoveData(Map<String, Object> model, UserBind elem, BindingResult result) throws Exception {
        return super.postRemoveData(model, elem, result);
    }

}